<!-- 雨量实况与预报 -->
<!-- 初步完结2024-10-8 -->
<template>
    <div class="container">
        <div style="display: flex; align-items: center; padding: 10px; color: #fff;">
            <span style="margin-right: 20px; font-weight: bold;">天气实况监测</span>
            <span style="margin-right: 20px;">|</span>
            <span style="display: flex; align-items: center;">
                <span>雨量实况与预报</span>
            </span>
        </div>


        <div class="content">
            <div class="title">
                <span>雨量实况与预报产品</span><br>
                <span>实况雨量统计时间:{{ tableData.collectTime }} 预报时间:{{ tableData.forecastTime }}</span>
            </div>
            <div class="table">
                <!-- 雨量 -->
                <el-table stripe :header-cell-style="headerCellStyle" :cell-style="cellStyle" :row-style="rowStyle"
                    :data="tableData.data" style="width: 100%;height: 100%" max-height="700px">
                    <el-table-column type="index" label="序号" align="center" sortable></el-table-column>
                    <el-table-column prop="wsName" label="气象站名" align="center" sortable></el-table-column>
                    <el-table-column prop="wsId" label="区站号" align="center" sortable></el-table-column>
                    <el-table-column prop="county" label="区县" align="center" sortable></el-table-column>
                    <el-table-column prop="rainMinute" label="分钟雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain1h" label="1小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain2h" label="2小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain3h" label="3小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain6h" label="6小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain12h" label="12小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain24h" label="24小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain48h" label="48小时雨量" align="center" sortable></el-table-column>
                    <el-table-column prop="rain1hYb" label="1小时预报" align="center" sortable></el-table-column>

                </el-table>
            </div>
            <!-- <div class="pagination">
                <el-pagination @current-change="handleCurrentChange" :current-page="currentPage" :page-size="pageSize"
                    layout="prev, pager, next" :total="total" background class="custom-pagination">
                </el-pagination>
            </div> -->
        </div>
    </div>
</template>

<script>
import Cookies from 'js-cookie';
import { reqRainAndForecast } from '@/api/monitor/index.js'
export default {
    data() {
        return {
            currentPage: 1,
            pageSize: 10,
            total: 10,
            // 雨量表格数据
            tableData: {
                data: [
                ],
                pageCount: 0,
                total: 0,
                collectTime: '',
                forecastTime: ""
            },
        }
    },
    mounted() {
        this.getData()
    },
    methods: {
        async getData() {
            let res = await reqRainAndForecast(Cookies.get('station_user'), this.currentPage, 100000)
            if (res.data.code = 200) {
                this.tableData.data = res.data.data.records
                this.tableData.pageCount = res.data.data.pageCount
                this.tableData.total = res.data.data.total
                this.tableData.forecastTime = res.data.data.records[0].forecastTime
                this.tableData.collectTime = res.data.data.records[0].time
            }
            else {
                this.$message.error(res.data.msg)
            }
        },
        // 翻页回调
        handleCurrentChange(current) {
            this.currentPage = current
            this.getData()
        },
        // 表格样式
        headerCellStyle() {
            return {
                background: '#0c2340',
                color: '#fff',
            };
        },
        cellStyle() {
            return {
                background: '#05152e',
                color: '#fff',
            };
        },
        rowStyle() {
            return {
                height: '30px',
            };
        },

    },
}
</script>

<style scoped lang="scss">
// 滚动条样式
::v-deep .el-table__body-wrapper {

    // 整个滚动条
    &::-webkit-scrollbar {
        width: 10px; // 纵向滚动条的宽度
        background: rgba(213, 215, 220, 0.3);

    }

    // 滚动条轨道
    &::-webkit-scrollbar-track {
        border: 5px solid white;
    }


}

// 滚动条的滑块
::v-deep .el-table__body-wrapper::-webkit-scrollbar-thumb {
    background-color: #0c2340;
    border-radius: 2px;
}

// --------------------隐藏table gutter列和内容区右侧的空白 start
::v-deep .el-table th.gutter {
    display: none;
    width: 0
}

::v-deep .el-table colgroup col[name='gutter'] {
    display: none;
    width: 0;
}

// 这个样式不加的话内容哪里会缺一点，估计是因为滚动条哪里缺的没有补上
::v-deep .el-table__body {
    width: 100% !important;
}

// --------------------隐藏table gutter列和内容区右侧的空白 end把以上改成css

.container {
    width: 100%;
    height: 100%;
    box-sizing: border-box;

    .content {
        width: 100%;

        .title {
            width: 100%;
            display: grid;
            place-items: center;

            span {
                color: white;
                font-weight: bold
            }

            margin: 20px 0;
        }

        .table {
            width: 100%;
        }

        .pagination {
            width: 100%;
            margin: 20px 0;
        }
    }
}
</style>